import React from 'react';
import ReactDOM from 'react-dom';

import { HashRouter as Router,Route,Switch} from 'react-router-dom';
import { Provider } from 'mobx-react';
import { asyncComponent } from 'react-async-component';
import { Tools, Bubble } from 'weaver-mobile';
import { FloatingTouch } from 'weaver-mobile-page';
import allStore from './stores';
import './style'
const getLabel = Tools.getLabel;

const coms = {
  Sms: asyncComponent({
    resolve: () => import('./components/index')
  }),
}

class Root extends React.Component {

  getLocaleLabel = Tools.getLocaleLabel;

  // constructor(props) {
  //   super(props);
  //   this.state = {
  //     loading: false
  //   }
  // }

  // componentDidMount() {
  //   Tools.ssoInit().then(() => {
  //     this.getLocaleLabel('sms_mobile', () => {
  //       this.setState({loading: true});
  //     });
  //   }).catch((res) => {
  //     Bubble.error(getLabel(386481, '登录失败') + "," + JSON.stringify(res), 0);
  //   });
  // }

  onHomePageClick() {
    window.location.href = '/#/';
  }

  render() {
    return (
      <Provider {...allStore} >
        <Router>
          <FloatingTouch onClick={() => this.onHomePageClick()}>
            <Route name='home' path='/' render={() => {
              // if(!this.state.loading) {
              //   return '';
              // }else{
                return (
                    <Switch>
                      <Route name='sms' breadcrumbName='短信' path='/sendSms' component={coms.Sms} />
                    </Switch>
                  );
                  // }
                }}/>
          </FloatingTouch>
        </Router>
      </Provider>
     
    )
  }
}
Tools.getLocaleLabel('sms_mobile',() => {
  ReactDOM.render(<Root />,document.getElementById('root'));
})